<?php
include '../../../wp-blog-header.php';

$deal = new Pod('deal');
//$deal->search = false;
$where = "camp_cat.url = 'c-fashion-offers' AND t.camp_end > ".fix_date();

$deal->findRecords('RAND()',6,$where);
$dealsFound = $deal->getTotalRows();

if($dealsFound > 0){
$op = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <title></title> 
   
  <style type="text/css">
    body{
    background-color: #ffffff;
    width:520px;

    margin:0;
    padding:0; 
    border:0;
    overflow: hidden;
    }
    
    .dealwrapper{
    width: 500px;
    }
        
    .deal{
    width: 160px;
    height: 290px;
    background-color: #ffffff;
    position: relative;
    margin-bottom: 5px;
    border: 1px solid #DBDBCC;
    float: left;
    }
    .deal a{
    text-decoration: none;
    font: bold 12px Arial, Helvetica, sans-serif;
    color: #000000;
    }
    .image{
    margin-top: 5px;
    margin-left: 5px;
    position: absolute;
    width:150px;
    height:150px;
    border: 1px solid #DBDBCC;
    text-align: center;
    top: 0px;
    left: 0px; 
    } 
    
    * html .image img{ 
    width: expression( document.body.clientWidth > 139 ? "140px" : "auto" ); /* sets max-width for IE */
    height: expression( document.body.clientHeight > 139 ? "140px" : "auto" ); /* sets max-height for IE */
     } 
       
    .image img{   
     max-width: 140px;
     max-height: 140px; 
    }
 
    .discount{
    position: absolute;
    top: 0px;
    right: 0px; 
    width: 50px;
    height: 50px;
    background: url(bubble.png);
    background-repeat: none;
    z-index: 1;
    font: bold 15px Arial, Helvetica, sans-serif;
    text-align: center;
    vertical-align: middle;
    color: #ffffff;
    }
 
    .title{
    margin-top: 160px;
    margin-left: 10px;
    width: 140px;
    text-align: justify;
   
    }
    
    .title a{
    text-decoration: none;
    font: bold 12px Arial, Helvetica, sans-serif;
    color: #000000;
    }
    .title a:hover{
    text-decoration: underline;
    background: none;
    color: #cc0000;
    }
    
    .lastPage{
    display: none;
    }
    
    .prevPage{
    display: none;    
    }
    
    .pageNum{
    font: 12px Arial, Helvetica, sans-serif;
    color:#666;
    }
    
    a:hover.pageNum{
    color: #cc0000;
    }
    
    .podPaginate { 
    margin-top:0px;
    -moz-border-radius:10px;
    -webkit-border-radius:10px;
    padding:0.8em;
    overflow:hidden;
    border-top:1px solid #eee;
    background:#f6f6f6;
    color:#666;
    margin-bottom:0.8em;
    width: 300px;
    }
    
    .firstPage{
    font: 12px Arial, Helvetica, sans-serif;
   
    text-decoration: underline;
   
    }
    
    .nextPage{
    font: 12px Arial, Helvetica, sans-serif;
    -moz-border-radius:10px;
    -webkit-border-radius:10px;
    text-decoration: none;
    border: 1px solid #000000;
     background-color: #3B5998;
    color: #ffffff;
    padding: 2px 3px 2px 3px;
    }
    
    a:hover.nextPage{
    background-color: #314A7E;
    }
  </style>
  </head>
  <body>';
  
  $deal->getPagination();
  $op.='<div class="dealwrapper">';
while($deal->fetchRecord()){
  $title = stripslashes($deal->get_field('name'));
  $discount = $deal->get_field('disper');
  $image_url = $deal->get_field('image.guid');
  if(empty($image_url)){
    $image_url = $deal->get_field('ext_image_url');
  }
 // $link = get_bloginfo('url').'/deals/'.$deal->get_field('camp_link').'?utm_source=fbbuzzrMumbai&utm_medium=facebook&utm_campaign=restaurant+offers';
    $link = get_bloginfo('url').'/deals/'.$deal->get_field('camp_link'); 
   if(!empty($image_url)){ 
   $op.= '<div class="deal">   
            <a href="'.$link.'" target="_blank"><div class="image">
              <img src="'.$image_url.'"/>';
              if (!empty($discount)){$op.='<div class="discount"><p>'.$discount.'%</p></div>'; }
          $op.=  '</div></a>
          <div class="title"><a href="'.$link.'" target="_blank">
              '.$title.'</a></div>
          </div>';
  }  
}
$op.= '</div>';
echo $op;
$deal->getPagination();
}

  
?>